//
//  FZNewfeatureCell.swift
//  FZSina_Swift
//
//  Created by 李忠 on 7/23/16.
//  Copyright © 2016 FZLZ. All rights reserved.
//

import UIKit

class FZNewfeatureCell: UICollectionViewCell {

    var index: NSInteger = 0{
        didSet{
            backIMGView.image = UIImage(named: "new_feature_\(index+1)")
            featureButton.hidden  = true
        }
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    func setupUI() {
        
        contentView.addSubview(backIMGView)
        contentView.addSubview(featureButton)
        
        
        backIMGView.snp_makeConstraints { (make) in
            make.edges.equalTo(UIEdgeInsetsZero)
        }
        featureButton.snp_makeConstraints { (make) in
            make.centerX.equalTo(contentView)
            make.bottom.equalTo(-50)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//MARK:==========================事件==========================
    func clickFeatureButton() {
//         NSNotificationCenter.defaultCenter().postNotificationName(FZSWITCHROOTVIEWCONTROLLER, object: "FZNewfeatureCell")
        NSNotificationCenter.defaultCenter().postNotificationName(FZSWITCHROOTVIEWCONTROLLER, object: nil)
    }

//MARK:==========================懒加载==========================
    
    lazy var backIMGView: UIImageView = UIImageView()
    
    lazy var featureButton: UIButton = {
       
        let btn: UIButton = UIButton(title: "立即体验", titleColor: UIColor.whiteColor(), backImageName: "new_feature_finish_button", target: self, action: #selector(clickFeatureButton))
        btn.setBackgroundImage(UIImage(named:"new_feature_finish_button_highlighted"), forState: .Highlighted)
        btn.titleLabel?.font = UIFont.systemFontOfSize(18)
        btn.hidden = true
        return btn
    }()
    
    
}
